import time
import grpc
import mygrpc.mygrpc_pb2
import mygrpc.mygrpc_pb2_grpc
from concurrent import futures

class EX1(mygrpc.mygrpc_pb2_grpc.wkxtestServicer):
    def call_func1(self, request, context):
        print('get from caller:',request)
        return mygrpc.mygrpc_pb2.server_return_type(data_type1 = 'in grpc server')

if __name__ == '__main__':
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    mygrpc.mygrpc_pb2_grpc.add_wkxtestServicer_to_server(EX1(),server)
    server.add_insecure_port('[::]:20000')
    server.start()
    try:
        while True:
            time.sleep(2)
            print('sleep 2ms')
    except Exception as e:
        print(e)
        server.stop()

